using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace G15_Agent.Models.Mapping
{
    public class NguoiDungMap : EntityTypeConfiguration<NguoiDung>
    {
        public NguoiDungMap()
        {
            // Primary Key
            this.HasKey(t => t.MaNguoiDung);

            // Properties
            this.Property(t => t.id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.MaNguoiDung)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.HoTen)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.NgaySinh)
                .HasMaxLength(50);

            this.Property(t => t.DiaChi)
                .HasMaxLength(200);

            this.Property(t => t.SoDT)
                .HasMaxLength(50);

            this.Property(t => t.TenDangNhap)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MatKhau)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.PhanQuyen)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("NguoiDung");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.MaNguoiDung).HasColumnName("MaNguoiDung");
            this.Property(t => t.HoTen).HasColumnName("HoTen");
            this.Property(t => t.NgaySinh).HasColumnName("NgaySinh");
            this.Property(t => t.DiaChi).HasColumnName("DiaChi");
            this.Property(t => t.SoDT).HasColumnName("SoDT");
            this.Property(t => t.TenDangNhap).HasColumnName("TenDangNhap");
            this.Property(t => t.MatKhau).HasColumnName("MatKhau");
            this.Property(t => t.PhanQuyen).HasColumnName("PhanQuyen");
            this.Property(t => t.TrangThai).HasColumnName("TrangThai");
        }
    }
}
